package test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author LovelyBigDuck
 * @date 2021/3/7 14:49
 */
public class Solution {
    public static int getMaxValue(int[] nums, int[] values) {
        // write code here
        int len = nums.length;
        List<Integer> list = new ArrayList<>();
        HashMap<Integer, Boolean> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] <= nums[len - 1 - i]) {
                list.add(nums[i]);
                map.put(i, true);
                if (map.get(len - 1 - i) == null) {
                    list.add(nums[len - 1 - i]);
                    map.put(nums[len - 1 - i], true);
                }
            }
        }
        int sum = 0;
        for (int i = 0; i < values.length; i++) {
            sum += list.get(i) * values[i];
        }
        return sum;
    }

    public static void main(String[] args) {
        int[] nums = {1, 3, 5, 2, 4};
        int[] values = {1, 2, 3, 4, 5};
        int maxValue = getMaxValue(nums, values);
        System.out.println(maxValue);
    }
}
